import 'package:flutter/material.dart';

/// 底部操作栏组件
class BottomActionBar extends StatelessWidget {
  /// 上传按钮点击回调
  final VoidCallback onUpload;

  /// 新建文件夹按钮点击回调
  final VoidCallback onCreateFolder;

  /// 排序按钮点击回调
  final VoidCallback onSort;

  const BottomActionBar({
    Key? key,
    required this.onUpload,
    required this.onCreateFolder,
    required this.onSort,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 60,
      padding: const EdgeInsets.symmetric(horizontal: 16),
      decoration: BoxDecoration(
        color: Theme.of(context).colorScheme.surface,
        boxShadow: [
          BoxShadow(
            color: Colors.black.withOpacity(0.1),
            blurRadius: 4,
            offset: const Offset(0, -1),
          ),
        ],
      ),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceAround,
        children: [
          _buildActionButton(
            context: context,
            icon: Icons.upload_file,
            label: '上传',
            onTap: onUpload,
          ),
          _buildActionButton(
            context: context,
            icon: Icons.create_new_folder,
            label: '新建文件夹',
            onTap: onCreateFolder,
          ),
          _buildActionButton(
            context: context,
            icon: Icons.sort,
            label: '排序',
            onTap: onSort,
          ),
        ],
      ),
    );
  }

  /// 构建操作按钮
  Widget _buildActionButton({
    required BuildContext context,
    required IconData icon,
    required String label,
    required VoidCallback onTap,
  }) {
    return GestureDetector(
      onTap: onTap,
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Icon(icon),
          const SizedBox(height: 4),
          Text(label, style: const TextStyle(fontSize: 12)),
        ],
      ),
    );
  }
}
